import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';

import error from '@dfeidao/atom-web/msgbox/error';

export default async function a011(fd: IFeidaoAiBrowserComponent) {
	// 添加
	const c_boxs = fd.data.node.querySelectorAll('[data-name="input"]:checked');
	if (c_boxs.length === 0) {
		error('请先选中至少一条数据');
		return;
	}
	const data = get(fd, 'origin_obj') as Map<string, { left: {}, right: Array<{}> }>;
	// console.log('a', data);

	// 'action_name', 'formid', 'action_keyword', 'code', 'productid'
	const agarr = Array.from(c_boxs).map((v) => {
		return {
			action_name: v.getAttribute('action_name'),
			formid: v.getAttribute('formid'),
			action_keyword: v.getAttribute('action_keyword'),
			code: v.getAttribute('code'),
			productid: v.getAttribute('productid')
		};
	});
	// console.log(agarr[0].formid);
	const formid = agarr[0].formid;
	// debugger;
	// if (Array.from(a.keys()).indexOf(formid) > -1) {
	const te = data.get(formid);
	te.right = agarr;
	// }
	set(fd, 'origin_obj', data);

	// console.log('a');
}
